import 'package:demo1/layout/Sample.dart';
import 'package:demo1/layout/TabbarPage.dart';
import 'package:flutter/material.dart';

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'Flutter Demo',
      theme: new ThemeData(
        // This is the theme of your application.
        //
        // Try running your application with "flutter run". You'll see the
        // application has a blue toolbar. Then, without quitting the app, try
        // changing the primarySwatch below to Colors.green and then invoke
        // "hot reload" (press "r" in the console where you ran "flutter run",
        // or press Run > Flutter Hot Reload in IntelliJ). Notice that the
        // counter didn't reset back to zero; the application is not restarted.
        primarySwatch: Colors.blue,
      ),
      home: new Scaffold(
          appBar: new AppBar(
            title: new Text('首页'),
          ),
          backgroundColor: Colors.red,
          body: new MyHomePage()),
    );
  }
}

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new ListView(
      children: [
        new PushButton('复杂布局(湖)', new LakeSample()),
        new PushButton('Tabbar', new TabbedAppBarSample()),
      ],
    );
  }
}

class PushButton extends StatelessWidget {
  final String text;

  final Widget widget;

  PushButton(this.text, this.widget);

  @override
  Widget build(BuildContext context) {
    return new Padding(
        padding: const EdgeInsets.all(8.0),
        child: new RaisedButton(
          child: new Text(text),
          onPressed: () {
            Navigator.push(context, new MaterialPageRoute(builder: (context) {
              return widget;
            }));
          },
        ));
  }
}
